﻿using UnityEngine;
using System.Collections;

public class TypeWritter : MonoBehaviour 
{
    public float delayPerCharacter = 0.05f;
    string _text;

    int currentPosition = 0;

    public void WriteText(string text)
    {
        guiText.text = "";
        _text = text;
        currentPosition = 0;
        StartCoroutine(TypeText());
    }

    IEnumerator TypeText()
    {
        while (currentPosition < _text.Length)
        {
            guiText.text += _text[currentPosition++];
            yield return new WaitForSeconds(delayPerCharacter);
        }    
    }
}
